#include <cstdio>
#include <cstring>

using namespace std;

char text[4010][210];
int nxt[210], a[210];
int ans;
char fans[210];
char t[210];
int n;

void extend_kmp( char *text1, char *text2 ){
	int i, j, k;
	nxt[0]=0;
	k=0;
	int tot1=strlen( text1 ), tot2=strlen( text2 );
	while ( 1+k<tot1 && text1[k]==text1[k+1] )
		k++;
	nxt[1]=k;
	k=1; j=2;
	while ( j<tot1 ){
		int l1=k+nxt[k]-1;
		int l2=nxt[j-k];
		if ( j+l2<=l1 )
			nxt[j]=l2;
		else{
			if ( l1>j )
				i=l1-j;
			else
				i=0;
			while ( j+i<tot1 && text1[i]==text1[j+i] ) i++;
			nxt[j]=i;
			k=j;
		}
		j++;
	}
	
	i=0;
	while ( i<tot1 && i<tot2 && text2[i]==text1[i] ) i++;
	a[0]=i;
	k=0;
	for ( int j=1; j<tot2; j++ ){
		int l1=k+a[k]-1;
		int l2=nxt[j-k];
		if ( j+l2<=l1 )
			a[j]=l2;
		else {
			if ( l1>j )
				i=l1-j;
			else
				i=0;
			while ( i<tot1 && j+i<tot2 && text1[i]==text2[j+i] ) i++;
			a[j]=i;
			k=j;
		}
	}
}

bool cmp( char *a, char *b ){
	int l=strlen(a);
	for ( int i=0; i<l; i++ ){
		if ( a[i]<b[i] ) return false;
		if ( a[i]>b[i] ) return true;
	}
	return false;
}

int main(){
	while ( scanf("%d ", &n)==1 && n ){
		for ( int i=0; i<n; i++ )
			gets( text[i] );
		ans=0;
		memset( fans, 0, sizeof( fans ) );
		for ( int i=0; i<strlen(text[0]); i++ ){
			int minn=10000;
			for ( int j=1; j<n; j++ ){
				extend_kmp( text[0]+i, text[j] );
				int maxx=0;
				for ( int k=0; k<strlen( text[j] ); k++ )
					if ( a[k]>maxx ) maxx=a[k];
				if ( maxx<minn ) minn=maxx;
			}
			if ( minn>ans ){
				ans=minn;
				strncpy( fans, text[0]+i, minn );
				fans[minn]='\0';
			} else
				if ( minn==ans ){
					strncpy( t, text[0]+i, minn );
					t[minn]='\0';
					if ( cmp( fans, t ) )
						strcpy( fans, t );
				}
		}
		if ( ans )
			printf("%s\n", fans);
		else
			printf("IDENTITY LOST\n");
	}
}
